// pages/tabBar/specialty/specialty.js
const http = require("../../../utils/httpUtils.js");
const app = getApp();
Page({
    data: {
        navbarData: {
            showCapsule: 0, //是否显示左上角图标
            title: '发现' //导航栏 中间的标题
        },
        height: app.globalData.height * 2 + 20,
        list: []
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.getList(1)
    },
    getList(pageNum, pageCount) {
        let data = {
            topic_id: 2,
            page: pageNum,
            pageCount: pageCount || 10
        };
        http._headerGet("/api/village/i_am_home", data, res => {
            if (res.data.code == 1) {
                if (pageNum == 1) { //下拉重置数据
                    this.setData({
                        list: res.data.data,
                        pageNum: pageNum
                    })
                } else {
                    this.setData({
                        list: [...this.data.list, ...res.data.data],
                        pageNum: pageNum
                    })
                }
            } else {
                wx.showToast({
                    title: res.data.msg,
                    icon: 'none'
                })
            }
        }, '', comp => {
            wx.stopPullDownRefresh()
        })
    },

    detail(e) { //进入详情
        let id = e.currentTarget.dataset.id;
        wx.navigateTo({
            url: `/pages/group/dynamicdetail/dynamicdetail?id=${id}`,
        })
    },
    publish() { //发布帖子页
        let identifier = 2;
        wx.navigateTo({
            url: `/pages/group/publish/publish?identifier=${identifier}`,
        })
    },

    onPullDownRefresh() {
        this.getList(1);
    },

    onReachBottom: function() {
        this.getList(this.data.pageNum + 1)
    },

    onShareAppMessage() {
        return {
            title: `打造地方最具代表性、独特性的"家乡特色名片"`
        }
    }
})